﻿<!DOCTYPE html>
<html>
	<head>
		<title>编辑模板</title>
    $css()
    <style type="text/css">
      #ifr{width:100%;z-index:0;}
      .tplinfo{position:absolute;right:1px;top:2px;z-index:100;}
    </style>
	</head>
<body style="overflow-y:hidden">
  <div class="tplinfo">
  <!--
    【当前视图目录】:<span class="txt">/templates/${systpl}/</span>&nbsp;&nbsp;<a href="?module=system&action=appconfig">设置</a>-->
     &nbsp;&nbsp;选择文件：<select class="tb_normal" id="files">${files}</select>
     &nbsp;&nbsp;创建样式文件：<input type="text" id="tplname" class="tb_normal" style="width:120px"/>
     <select id="tpltype" class="tb_normal" style="width:100px;display:none"><option value="0">页面视图</option><option value="1">部分视图</option></select>
     <input type="button" value="创建" class="btn" id="createview" />
  </div>
  <iframe id="ifr" src="about:blank" frameborder="0" scrolling="no"></iframe>
$js()
  <script type="text/javascript">
    var filelist = document.getElementById('files'),
      ifr = document.getElementById("ifr");

    ifr.style.height = (document.documentElement.clientHeight) + "px";
    var src = '';
    for (var i = 0; i < filelist.options.length; i++) {
        if (filelist.options[i].value.indexOf('/index.html') != -1) {
            src = filelist.options[i].value;
            filelist.options[i].setAttribute('selected', 'selected');
            break;
        }
    }

        if (src == '') {
            src = filelist.options[0].value;
        }
        ifr.src = '?module=file&action=editfile&path=' + src;


        filelist.onchange = function () {
            ifr.src = '?module=file&action=editfile&path=' + this.value;
        };

        cms.$('createview').onclick = (function (t) {
            return function () {
                var tplname = cms.val('tplname');
                var tpltype = cms.val('tpltype');
                if (tplname != '') {
                    cms.xhr.post('?', 'module=file&action=createstylesheet&name=' + tplname + '&type=' + tpltype, function (x) {
                        if (x.indexOf('.') == -1) {
                            parent.M.alert(x);
                        } else {
                            location.replace('?module=file&action=edit&file=' + x);
                        }
                    });
                }
            };
        })(this);
  </script>
</body>
</html>